# def rotate(matrix):
#         n = len(matrix)
#         for i in range(n // 2):
#             for j in range((n + 1) // 2):
#                 matrix[i][j], matrix[n - j - 1][i], matrix[n - i - 1][n - j - 1], matrix[j][n - i - 1] \
#                     = matrix[n - j - 1][i], matrix[n - i - 1][n - j - 1], matrix[j][n - i - 1], matrix[i][j]
#         return matrix
# if __name__ == '__main__':
#  n = int(input('7'))
#  line = [[0]*n]*n
#  for i in range(n):
#     line[i] = input('a').split(" ")
#  y=rotate(line)
#  print(y)


# pip install moviepy
from moviepy.editor import VideoFileClip
from PIL import Image
import os

clip1 = VideoFileClip('./car.mp4')
i = 1
path='./results3'
if not os.path.exists(path):
    os.makedirs(path)

for frame in clip1.iter_frames(fps=0.1):
    im = Image.fromarray(frame)
    im.save("./results3/your_file_%07d.jpg" % i)
    i = i+1


# from moviepy.editor import VideoFileClip
#
# # 读取视频文件
# clip = VideoFileClip("demo.mp4")
#
# # 以每秒20帧的方式获取图片帧
# for i, img in enumerate(clip.iter_frames(fps=20)):
#   # todo 对图片进行识别